package com.union.utils;

import android.content.Context;
import android.view.Gravity;
import android.view.Window;

import com.union.dialog.ContentSelectedDialog;
import com.union.unionht.R;


/**
 * 弹出框选择
 * @ClassName   CommonSelectDialogUtils
 * @author       create  2016/10/26  14:54 by xiaobo
 * @version        1.0
 * */
public class CommonSelectDialogUtils {

    private Context context;
    private DataDialogCallBack dialogCallBack;

    public void setDialogCallBack(DataDialogCallBack dialogCallBack) {
        this.dialogCallBack = dialogCallBack;
    }

    public void getDialog(Context context, String[] data, int visiableCount) {
        ContentSelectedDialog contentSelectedDialog = new ContentSelectedDialog(context,"", "", data,visiableCount,new ContentSelectedDialog.PriorityListener() {
            @Override
            public void refreshPriorityUI(String content) {
                if(dialogCallBack != null){
                    dialogCallBack.selectData(content);
                }
            }
        });
        Window window = contentSelectedDialog.getWindow();
        window.setGravity(Gravity.BOTTOM); // 此处可以设置dialog显示的位置
        window.setWindowAnimations(R.style.dialogstyle); // 添加动画
        contentSelectedDialog.setCancelable(true);
        contentSelectedDialog.show();

    }


    public interface DataDialogCallBack {
        void selectData(String content);
    }
}
